package cc.zy.base.hr.controller;

import cc.zy.base.common.entity.FebsConstant;
import cc.zy.base.common.utils.DateUtil;
import cc.zy.base.common.utils.FebsUtil;
import cc.zy.base.hr.entity.ScoreIntegral;
import cc.zy.base.hr.entity.StaffLabel;
import cc.zy.base.hr.entity.StaffSyncLog;
import cc.zy.base.hr.service.IHrDeptService;
import cc.zy.base.hr.service.IScoreIntegralService;
import cc.zy.base.hr.service.IStaffService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Date;

/**
 * @author ljy
 * @time 2022/03/05 12:00:05
 */
@Slf4j
@Controller
@RequiredArgsConstructor
public class ViewController {

    @Autowired
    private IStaffService staffService;

    @Autowired
    private IScoreIntegralService scoreIntegralService;

    @Autowired
    private IHrDeptService deptService;

    /**
     * 转跳到标签列表管理页面
     */
    @GetMapping(FebsConstant.VIEW_PREFIX+"staffLabel/list")
    public String goStaffLabelList(){
        return FebsUtil.hrView("staffLabel/staffLabel");
    }

    /**
     * 转跳到员工列表管理页面
     */
    @GetMapping(FebsConstant.VIEW_PREFIX+"staff/list")
    public String goStaffList(Model model){
        Date updateTime = staffService.getUpdateTime();
        resolveUpdateTime(updateTime, model, true);
        return FebsUtil.hrView("staff/staff");
    }

    /**
     * 转跳到员工同步日志页面
     */
    @GetMapping(FebsConstant.VIEW_PREFIX+"staff/syncloglist")
    public String goStaffLog(){
        return FebsUtil.hrView("staff/staffSyncLog");
    }

    /**
     * 修改更新的数据格式,将数据放到页面里
     */
    private void resolveUpdateTime(Date updateTime, Model model, Boolean transform) {

        if (updateTime != null) {
            model.addAttribute("updateTime", DateUtil.getDateFormat(updateTime, DateUtil.FULL_TIME_SPLIT_PATTERN));
        }
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "course/list")
    public String course() {
        return FebsUtil.hrView("course/course");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "outsideTeacher/goList")
    public String outsideTeacherIndex() {
        return FebsUtil.hrView("outsideTeacher/outsideTeacher");
    }

    /**
     * 跳转培训批次页面
     *
     * @return
     */
    @GetMapping(FebsConstant.VIEW_PREFIX + "trainningBatch/list")
    public String goTrainningBatch() {
        return FebsUtil.hrView("trainningBatch/trainningBatch");
    }


    /**
     * 积分展示表跳转
     * @param id
     * @param model
     * @return
     */
    @GetMapping(FebsConstant.VIEW_PREFIX + "scoreIntegral/list")
    public String scoreIntegral() {
        return FebsUtil.hrView("scoreIntegral/scoreIntegral");
    }

    /**
     * 方法描述：跳转到上传薪酬文件的页面
     *
     * @return
     * @author LiuZhuang
     * @date 2022/03/08
     *
     */
    @GetMapping(FebsConstant.VIEW_PREFIX + "emolumentExcel/view")
    public String goEmolumentExcel() {
        return FebsUtil.hrView("emolument/emolumentExcel");
    }

    /**
     * 方法描述：跳转到
     *
     * @return
     * @author XioaZh
     * @date 2022/03/08
     *
     */
    @GetMapping(FebsConstant.VIEW_PREFIX + "emolument/view")
    public String goEmolument() {
        return FebsUtil.hrView("emolument/emolument");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "examineSimple/goList")
    public String examineSimple() {
        return FebsUtil.hrView("examineSimple/examineSimple");
    }

    /**
     * 积分规则表跳转
     * @param
     * @param
     * @return
     */
    @GetMapping(FebsConstant.VIEW_PREFIX + "scoreMapping/list")
    public String scoreMapping() {
        return FebsUtil.hrView("scoreMapping/scoreMapping");
    }

    @GetMapping(FebsConstant.VIEW_PREFIX + "outsideTeacher/list")
    public String outsideTeacher() {
        return FebsUtil.hrView("outsideTeacher/outsideTeacherForSelect");
    }




    /**
     * 转跳到部门管理页面
     */
    @GetMapping(FebsConstant.VIEW_PREFIX + "hrDept/list")
    public String dept(Model model) {
        Date updateDate = deptService.getHrDeptUpdateDate();
        resolveUpdateTime(updateDate,model,true);
        return FebsUtil.hrView("hrDept/hrDept");
    }

    /**
     * 修改更新的数据格式,将数据放到页面里
     */
    private void resolveUpdateTime(Date updateDate, Model model, boolean b) {
        if (updateDate != null) {
            model.addAttribute("updateDate", DateUtil.getDateFormat(updateDate, DateUtil.FULL_TIME_SPLIT_PATTERN));
        }
    }

    /**
     * 转跳到部门同步日志页面
     */
    @GetMapping(FebsConstant.VIEW_PREFIX+"hrDept/synloglist")
    public String goHrDeptLog(){
        return FebsUtil.hrView("hrDept/hrDeptSynLog");
    }

    /**
     * @Author: dyq
     * @Description: 查通用组件选择员工
     * @DateTime: 2022/3/11 16:50
     */
    @GetMapping(FebsConstant.VIEW_PREFIX + "staff/goList")
    public String staff() {
        return FebsUtil.hrView("staff/staffSelect");
    }

    /**
     * @author zhangyihao
     * 侧边菜单到执行计划管理页面
     * @return
     */
    @GetMapping(FebsConstant.VIEW_PREFIX + "executeSchedule/goList")
    public String executeScheduleIndex() {
        System.out.println("33333");
        return FebsUtil.hrView("plan/execute/executeSchedule");
    }


    /**
     * @author zhangyihao
     * 页面侧面主菜单跳转到 草稿管理主页面
     * @return
     */
    @GetMapping(FebsConstant.VIEW_PREFIX + "trainningPlanDraft/list")
    public String trainningPlanDraftHome() {
        return FebsUtil.hrView("plan/draft/trainningPlanDraft");
    }

}
